package com.iyundao.io.mapper;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SET;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.UPDATE;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;
import static org.apache.ibatis.jdbc.SqlBuilder.WHERE;

import com.iyundao.io.model.SysLog;
import org.springframework.stereotype.Repository;


@Repository
public class SysLogSqlProvider {

    public String insertSelective(SysLog record) {
        BEGIN();
        INSERT_INTO("sys_log");
        
        if (record.getSid() != null) {
            VALUES("sid", "#{sid,jdbcType=CHAR}");
        }
        
        if (record.getOperationName() != null) {
            VALUES("operation_name", "#{operationName,jdbcType=VARCHAR}");
        }
        
        if (record.getOperationType() != null) {
            VALUES("operation_type", "#{operationType,jdbcType=VARCHAR}");
        }
        
        if (record.getParameter() != null) {
            VALUES("parameter", "#{parameter,jdbcType=VARCHAR}");
        }
        
        if (record.getResults() != null) {
            VALUES("results", "#{results,jdbcType=VARCHAR}");
        }
        
        if (record.getSysMsg() != null) {
            VALUES("sys_msg", "#{sysMsg,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateDate() != null) {
            VALUES("create_date", "#{createDate,jdbcType=TIMESTAMP}");
        }
        
        if (record.getCreateId() != null) {
            VALUES("create_id", "#{createId,jdbcType=CHAR}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(SysLog record) {
        BEGIN();
        UPDATE("sys_log");
        
        if (record.getOperationName() != null) {
            SET("operation_name = #{operationName,jdbcType=VARCHAR}");
        }
        
        if (record.getOperationType() != null) {
            SET("operation_type = #{operationType,jdbcType=VARCHAR}");
        }
        
        if (record.getParameter() != null) {
            SET("parameter = #{parameter,jdbcType=VARCHAR}");
        }
        
        if (record.getResults() != null) {
            SET("results = #{results,jdbcType=VARCHAR}");
        }
        
        if (record.getSysMsg() != null) {
            SET("sys_msg = #{sysMsg,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateDate() != null) {
            SET("create_date = #{createDate,jdbcType=TIMESTAMP}");
        }
        
        if (record.getCreateId() != null) {
            SET("create_id = #{createId,jdbcType=CHAR}");
        }
        
        WHERE("sid = #{sid,jdbcType=CHAR}");
        
        return SQL();
    }
}